package top.hundreds.oasys.bean.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Getter
public enum MatterStatus {
    UNFINISHED(0, "未完成"),
    FINISHED(1, "已完成");

    @JsonValue
    @EnumValue
    private final Integer value;

    private final String label;

    public static MatterStatus formValue(Object o) {
        if (o != null) {
            MatterStatus[] statuses = values();
            for (MatterStatus status : statuses) {
                if (status.getValue().equals(o)) {
                    return status;
                }
            }
        }
        return null;
    }

    public static MatterStatus formLabel(Object o) {
        if (o != null) {
            MatterStatus[] statuses = values();
            for (MatterStatus status : statuses) {
                if(status.getLabel().equals(o)){
                    return status;
                }
            }
        }
        return null;
    }
}
